unit SmallStruct.Configuration.TSSViewConfiguration;

interface

uses
  Classes,
  SmallStruct.Core,
  SmallStruct.Configuration.TSSConfiguration,
  SmallStruct.Configuration;

type
  TSSViewFieldConfiguration = class(TSSConfiguration, ISSViewFieldConfiguration)
  private
    _Height, _Col, _Row, _Width: Integer;
    _FieldName, _LinkFieldName, _LinkModelName, _LinkKeyFieldName: string;
    _IsVisiable: Boolean;
    _Type: TSSViewFieldType;
  public
    function GetFieldName: string;
    function GetCol: Integer;
    function GetHeight: Integer;
    function GetLinkFieldName: string;
    function GetLinkModelName: string;
    function GetLinkKeyFieldName: string;
    function GetRow: Integer;
    function GetType: TSSViewFieldType;
    function GetWidth: Integer;
    function IsVisiable: Boolean;
  public
    procedure SetFieldName(const AFieldName: string);
    procedure SetCol(const ACol: Integer);
    procedure SetHeight(const AHeight: Integer);
    procedure SetLinkFieldName(const ALinkFieldName: string);
    procedure SetLinkModelName(const ALinkModelName: string);
    procedure SetLinkKeyFieldName(const ALinkKeyFieldName: string);
    procedure SetRow(const ARow: Integer);
    procedure SetType(const AType: TSSViewFieldType);
    procedure SetWidth(const AWidth: Integer);
    procedure SetVisiable(const AIsVisiable: Boolean);
  end;

  TSSViewConfiguration = class(TSSConfiguration, ISSViewConfiguration)
  private
    _ViewName, _PrimaryModelName: string;
    _Type: TSSViewType;
    _IsMultiDataChoose, _IsReadOnly: Boolean;
    _ModelName, _InnerViewName: TStringList;
    _FieldConfiguration: ISSObjectContainer;
  public
    function GetViewName: string;
    function GetModelName: TStrings;
    function GetFieldConfiguration: ISSObjectContainer;
    function GetInnerViewName: TStrings;
    function GetPrimaryModelName: string;
    function GetType: TSSViewType;
    function IsMultiDataChoose: Boolean;
    function IsReadOnly: Boolean;
  public
    procedure SetViewName(const AViewName: string);
    procedure SetPrimaryModelName(const APrimaryModelName: string);
    procedure SetType(const AType: TSSViewType);
    procedure SetMultiDataChoose(const AIsMultiDataChoose: Boolean);
    procedure SetReadOnly(const AIsReadOnly: Boolean);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation

uses SmallStruct.Core.TSSObjectContainer;

{ TSSViewFieldConfiguration }

function TSSViewFieldConfiguration.GetWidth: Integer;
begin
  Result := _Width;
end;

function TSSViewFieldConfiguration.GetCol: Integer;
begin
  Result := _Col;
end;

function TSSViewFieldConfiguration.GetFieldName: string;
begin
  Result := _FieldName;
end;

procedure TSSViewFieldConfiguration.SetWidth(const AWidth: Integer);
begin
  _Width := AWidth;
end;

function TSSViewFieldConfiguration.GetLinkModelName: string;
begin
  Result := _LinkModelName;
end;

function TSSViewFieldConfiguration.GetRow: Integer;
begin
  Result := _Row;
end;

function TSSViewFieldConfiguration.GetType: TSSViewFieldType;
begin
  Result := _Type;
end;

function TSSViewFieldConfiguration.GetLinkFieldName: string;
begin
  Result := _LinkFieldName;
end;

function TSSViewFieldConfiguration.GetLinkKeyFieldName: string;
begin
  Result := _LinkKeyFieldName;
end;

procedure TSSViewFieldConfiguration.SetCol(const ACol: Integer);
begin
  _Col := ACol;
end;

procedure TSSViewFieldConfiguration.SetFieldName(const AFieldName: string);
begin
  _FieldName := AFieldName;
end;

function TSSViewFieldConfiguration.GetHeight: Integer;
begin
  Result := _Height;
end;

function TSSViewFieldConfiguration.IsVisiable: Boolean;
begin
  Result := _IsVisiable;
end;

procedure TSSViewFieldConfiguration.SetLinkModelName(const ALinkModelName: string);
begin
  _LinkModelName := ALinkModelName;
end;

procedure TSSViewFieldConfiguration.SetRow(const ARow: Integer);
begin
  _Row := ARow;
end;

procedure TSSViewFieldConfiguration.SetType(const AType: TSSViewFieldType);
begin
  _Type := AType;
end;

procedure TSSViewFieldConfiguration.SetLinkFieldName(const ALinkFieldName: string);
begin
  _LinkFieldName := ALinkFieldName;
end;

procedure TSSViewFieldConfiguration.SetLinkKeyFieldName(const ALinkKeyFieldName: string);
begin
  _LinkKeyFieldName := ALinkKeyFieldName;
end;

procedure TSSViewFieldConfiguration.SetVisiable(const AIsVisiable: Boolean);
begin
  _IsVisiable := AIsVisiable;
end;

procedure TSSViewFieldConfiguration.SetHeight(const AHeight: Integer);
begin
  _Height := AHeight;
end;

{ TSSViewConfiguration }

constructor TSSViewConfiguration.Create(AOwner: TComponent);
begin
  inherited;
  _ModelName := TStringList.Create;
  _InnerViewName := TStringList.Create;
  _FieldConfiguration := TSSObjectContainer.Create(Self);
end;

function TSSViewConfiguration.GetModelName: TStrings;
begin
  Result := _ModelName;
end;

function TSSViewConfiguration.GetType: TSSViewType;
begin
  Result := _Type;
end;

function TSSViewConfiguration.GetViewName: string;
begin
  Result := _ViewName;
end;

function TSSViewConfiguration.GetPrimaryModelName: string;
begin
  Result := _PrimaryModelName;
end;

function TSSViewConfiguration.IsReadOnly: Boolean;
begin
  Result := _IsReadOnly;
end;

procedure TSSViewConfiguration.SetType(const AType: TSSViewType);
begin
  _Type := AType;
end;

procedure TSSViewConfiguration.SetViewName(const AViewName: string);
begin
  _ViewName := AViewName;
end;

procedure TSSViewConfiguration.SetPrimaryModelName(const APrimaryModelName: string);
begin
  _PrimaryModelName := APrimaryModelName;
end;

destructor TSSViewConfiguration.Destroy;
begin
  _ModelName.Free;
  _InnerViewName.Free;
  _FieldConfiguration.ReleaseObject;
  _FieldConfiguration.ReleaseObjectInstance;
  inherited;
end;

procedure TSSViewConfiguration.SetReadOnly(const AIsReadOnly: Boolean);
begin
  _IsReadOnly := AIsReadOnly;
end;

function TSSViewConfiguration.GetFieldConfiguration: ISSObjectContainer;
begin
  Result := _FieldConfiguration;
end;

function TSSViewConfiguration.GetInnerViewName: TStrings;
begin
  Result := _InnerViewName;
end;

procedure TSSViewConfiguration.SetMultiDataChoose(const AIsMultiDataChoose: Boolean);
begin
  _IsMultiDataChoose := AIsMultiDataChoose;
end;

function TSSViewConfiguration.IsMultiDataChoose: Boolean;
begin
  Result := _IsMultiDataChoose;
end;

end.
